<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0">
    <title>订单详情 - 钢域云贸</title>
    <link rel="icon" href="/uploads/logo.png" type="image/x-icon"/>
    <link rel="shortcut icon" href="/uploads/logo.png" type="image/x-icon"/>
    <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css" media="all"/>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.tailwindcss.com"></script>
    <style>
        /* 订单详情容器 */
        .order-detail {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 2rem;
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        }

        /* 各部分标题 */
        .detail-section h3 {
            font-size: 1.25rem;
            font-weight: 600;
            color: #333333;
            padding-bottom: 0.75rem;
            border-bottom: 1px solid #e5e7eb;
            margin-bottom: 1.5rem;
            position: relative;
        }

        .detail-section h3::after {
            content: "";
            position: absolute;
            left: 0;
            bottom: -1px;
            width: 80px;
            height: 2px;
            background-color: #3b82f6;
        }

        /* 信息行样式 */
        .info-row {
            display: flex;
            margin-bottom: 1rem;
            line-height: 1.5;
        }

        .info-label {
            font-weight: 500;
            color: #666666;
            min-width: 100px;
            margin-right: 1rem;
        }

        /* 商品表格样式 */
        .product-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 1rem;
            font-size: 0.9rem;
        }

        .product-table th {
            background-color: #f8fafc;
            padding: 0.75rem 1rem;
            text-align: left;
            font-weight: 600;
            color: #475569;
            border-bottom: 1px solid #e2e8f0;
        }

        .product-table td {
            padding: 0.75rem 1rem;
            border-bottom: 1px solid #e2e8f0;
            vertical-align: top;
        }

        .product-table tr:hover td {
            background-color: #f8fafc;
        }

        /* 按钮区域样式 */
        .order-back {
            text-align: right;
            margin-top: 2rem;
        }

        /* 按钮基础样式 */
        .btn-back, .btn-ship {
            padding: 0.5rem 1.25rem;
            border-radius: 4px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-back {
            background-color: #f1f5f9;
            color: #475569;
            border: 1px solid #e2e8f0;
        }

        .btn-back:hover {
            background-color: #e2e8f0;
        }

        .btn-ship {
            background-color: #10b981;
            color: white;
            border: 1px solid #10b981;
        }

        .btn-ship:hover {
            background-color: #059669;
        }

        /* 表单样式 */
        .form-group {
            margin-bottom: 1rem;
        }

        .form-group label {
            display: block;
            font-weight: 500;
            color: #666666;
            margin-bottom: 0.25rem;
        }

        .form-input {
            width: 100%;
            padding: 0.5rem;
            border: 1px solid #e2e8f0;
            border-radius: 4px;
            box-sizing: border-box;
        }

        .form-input:focus {
            border-color: #3b82f6;
            outline: none;
            box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
        }

        /* 响应式调整 */
        @media (max-width: 768px) {
            .order-detail {
                padding: 1rem;
            }

            .product-table {
                display: block;
                overflow-x: auto;
            }

            .info-row {
                flex-direction: column;
                margin-bottom: 1.5rem;
            }

            .info-label {
                margin-bottom: 0.25rem;
            }

            .form-group {
                margin-bottom: 1.5rem;
            }
        }
    </style>
</head>
<body>
<th:block th:replace="~{/header.html}"></th:block>
<div class="container">
    <div class="order-detail">
        <div class="detail-section">
            <h3>订单信息</h3>
            <div class="info-row">
                <span class="info-label">订单编号:</span>
                <span th:text="${order.orderNo}"></span>
            </div>
            <div class="info-row">
                <span class="info-label">买家ID:</span>
                <span th:text="${order.buyerId}"></span>
            </div>
            <div class="info-row">
                <span class="info-label">总金额:</span>
                <span th:text="'￥' + ${#numbers.formatDecimal(order.totalAmount, 1, 2)}"></span>
            </div>
            <div class="info-row">
                <span class="info-label">订单状态:</span>
                <span th:text="${order.status == 'PENDING'? '待支付' : (order.status == 'PAID'? '已支付' : (order.status == 'SHIPPED'? '已发货' : (order.status == 'COMPLETED'? '已完成' : (order.status == 'CANCELLED'? '已取消' : '未知'))))}"></span>
            </div>
            <div class="info-row">
                <span class="info-label">支付时间:</span>
                <span th:text="${order.paymentTime != null} ? ${#dates.format(order.paymentTime, 'yyyy-MM-dd HH:mm')} : '--'"></span>
            </div>
        </div>
        <div class="detail-section">
            <h3>收货信息</h3>
            <div class="info-row">
                <span class="info-label">收货人:</span>
                <span th:text="${order.contactName}"></span>
            </div>
            <div class="info-row">
                <span class="info-label">联系电话:</span>
                <span th:text="${order.contactPhone}"></span>
            </div>
            <div class="info-row">
                <span class="info-label">收货地址:</span>
                <span th:text="${order.deliveryAddress}"></span>
            </div>
        </div>
        <div class="detail-section" th:if="${order.status == 'PAID' || order.status == 'SHIPPED' || order.status == 'COMPLETED'}">
            <h3>物流信息</h3>
            <div class="info-row" th:if="${order.shippingCompany} != null">
                <span class="info-label">物流公司:</span>
                <span th:text="${order.shippingCompany}"></span>
            </div>
            <div class="info-row" th:if="${order.trackingNumber} != null">
                <span class="info-label">物流单号:</span>
                <span th:text="${order.trackingNumber}"></span>
            </div>
            <div class="info-row" th:if="${order.shippingAddress} != null">
                <span class="info-label">发货地址:</span>
                <span th:text="${order.shippingAddress}"></span>
            </div>
            <form th:action="@{'/supplier/order/ship/' + ${order.orderNo}}" method="post" th:if="${order.status == 'PAID'}">
                <input type="hidden" name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
                <div class="form-group">
                    <label for="shippingCompany">物流公司</label>
                    <input type="text" id="shippingCompany" name="shippingCompany" required class="form-input">
                </div>
                <div class="form-group">
                    <label for="trackingNumber">物流单号</label>
                    <input type="text" id="trackingNumber" name="trackingNumber" required class="form-input">
                </div>
                <div class="form-group">
                    <label for="shippingAddress">发货地址</label>
                    <input type="text" id="shippingAddress" name="shippingAddress" required class="form-input">
                </div>
                <button type="submit" class="btn-ship">确认发货</button>
            </form>
        </div>
        <div class="detail-section">
            <h3>商品列表</h3>
            <table class="product-table">
                <thead>
                <tr>
                    <th>商品ID</th>
                    <th>商品名称</th>
                    <th>数量</th>
                    <th>单价</th>
                    <th>总价</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="item : ${order.items}">
                    <td th:text="${item.productId}"></td>
                    <td th:text="${item.productName}"></td>
                    <td th:text="${item.quantity}"></td>
                    <td th:text="'￥' + ${#numbers.formatDecimal(item.price, 1, 2)}"></td>
                    <td th:text="'￥' + ${#numbers.formatDecimal(item.totalPrice, 1, 2)}"></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="order-back">
        <button class="btn-back" onclick="window.location.href='/supplier/order/list'">返回订单列表</button>
    </div>
</div>
<th:block th:replace="~{/footer.html}"></th:block>
<script src="/js/jquery-latest.min.js"></script>
<script src="/js/popper.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</body>

</html>
